package com.ruoyi.resume.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.resume.domain.request.LabelingRequest;
import com.ruoyi.resume.service.BasicInfoLabelingService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "标签识别与存储")
@RestController
@RequestMapping("/basic-info-labeling")
public class BasicInfoLabelingController {

    @Autowired
    private BasicInfoLabelingService basicInfoLabelingService;

    /**
     * 生成性别标签
     * @param request 包含基本信息的对象
     * @return 性别标签键值对列表
     */
    @ApiOperation(value = "生成性别标签",
            notes = "通过传入性别信息，生成对应的性别标签")
    @PostMapping("/gender")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> basicInfoLabelingGender(
            @ApiParam(value = "包含基本信息的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成性别标签
        List<Map<String, Integer>> result = basicInfoLabelingService.generateGenderLabel(request);
        return ResponseEntity.ok(result);
    }

    /**
     * 生成年龄标签
     * @param request 包含基本信息的对象
     * @return 年龄标签键值对列表
     */
    @ApiOperation(value = "生成年龄标签",
            notes = "通过传入年龄信息，生成对应的年龄标签")
    @PostMapping("/age")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> basicInfoLabelingAge(
            @ApiParam(value = "包含基本信息的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成年龄标签
        List<Map<String, Integer>> result = basicInfoLabelingService.generateAgeLabel(request);
        return ResponseEntity.ok(result);
    }

    /**
     * 生成政治面貌标签
     * @param request 包含基本信息的对象
     * @return 政治面貌标签键值对列表
     */
    @ApiOperation(value = "生成政治面貌标签",
            notes = "通过传入政治面貌信息，生成对应的政治面貌标签")
    @PostMapping("/political-status")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> basicInfoLabelingPoliticalStatus(
            @ApiParam(value = "包含基本信息的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成政治面貌标签
        List<Map<String, Integer>> result = basicInfoLabelingService.generatePoliticalStatusLabel(request);
        return ResponseEntity.ok(result);
    }

    /**
     * 生成籍贯标签
     * @param request 包含籍贯信息的对象
     * @return 籍贯标签键值对列表
     */
    @ApiOperation(value = "生成籍贯标签",
            notes = "通过传入籍贯信息，生成对应的籍贯标签")
    @PostMapping("/hometown")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> generateHometownLabel(
            @ApiParam(value = "包含籍贯信息的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成籍贯标签
        List<Map<String, Integer>> result = basicInfoLabelingService.generateHometownLabel(request);

        // 返回键值对列表
        return ResponseEntity.ok(result);
    }

    /**
     * 生成民族标签
     * @param request 包含基本信息的对象
     * @return 民族标签键值对列表
     */
    @ApiOperation(value = "生成民族标签",
            notes = "通过传入民族信息，生成对应的民族标签")
    @PostMapping("/ethnicity")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> basicInfoLabelingEthnicity(
            @ApiParam(value = "包含基本信息的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成民族标签
        List<Map<String, Integer>> result = basicInfoLabelingService.generateEthnicityLabel(request);
        return ResponseEntity.ok(result);
    }
}
